//
//  AlertHelper.m
//  hah
//
//  Created by chuanglong03 on 16/5/19.
//  Copyright © 2016年 chuanglong02. All rights reserved.
//

#import "AlertHelper.h"

@implementation AlertHelper

#pragma mark - 单例
+ (AlertHelper *)sharedManager {
    static AlertHelper *handle = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        handle = [[AlertHelper alloc] init];
    });
    return handle;
}

#pragma mark - 提示框
- (void)alertWithMessage:(NSString *)message {
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
    label.font = [UIFont systemFontOfSize:14];
    label.textAlignment = NSTextAlignmentCenter;
    label.text = message;
    [label sizeToFit];
    label.backgroundColor = [UIColor grayColor];
    label.textColor = [UIColor whiteColor];
//    label.center = CGPointMake(Device_Width/2.0, Device_Height-60);
    [label.layer layoutIfNeeded];
    
    label.layer.cornerRadius = 3;
    label.layer.masksToBounds = YES;
    
    [[UIApplication sharedApplication].keyWindow addSubview:label];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [label removeFromSuperview];
    });
}

@end
